<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="/common_head :: commonHead('pie')"></head>
<body>
<div class="page-container">
    <div class="left-content">
        <div class="inner-content">
            <div class="header-section">
                <div th:include="/header :: header"></div>
                <div class="clearfix"></div>
            </div>
            <div class="outter-wp">
                <div class="sub-heard-part">
                    <ol class="breadcrumb m-b-0">
                        <li><a href="index.html">Home</a></li>
                        <li class="active">Data</li>
                    </ol>
                </div>
            </div>
            <div class="graph-visual">
                <h2 class="inner-tittle">我的数据集</h2>
                <div class="graph">
                    <div class="map_container">
                            <input type="file" id="file" name="file"/>
                            <a class="btn blue four" type="button" id="upload">上传数据</a>
                    </div>
                    <div class="graph">
                        <div class="tables">
                            <table class="table">
                                <thead>
                                <tr>
                                    <th>#</th>
                                    <th>数据集</th>
                                    <th>上传时间</th>
                                    <th>所属者</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody th:each="file:${list}">
                                <tr th:if="${file}">
                                    <th scope="row">.</th>
                                    <td><label th:text="${file.getName()}"></label></td>
                                    <td><label th:text="${file.getCreateTime()}"></label></td>
                                    <td><label th:text="${file.getOwner()}"></label></td>
                                    <td><a th:href="@{'/rmFile/'+${file.getName()}}">删除</a>|<a th:href="@{'/downFile/'+${file.getName()}}">下载</a></td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <footer th:include="/footer :: footer">
                </footer>
            </div>
        </div>
        <div class="sidebar-menu" th:include="/sidebar :: sidebar"></div>
        <div class="clearfix"></div>
    </div>
</div>
<script>
    $("#upload").click(function () {
        var form=new FormData();
        form.append("file", $("#file")[0].files[0]);
        $.ajax({
            type:"post",
            url: "uploadFile",
            data:form,
            processData: false,  // 告诉jQuery不要去处理发送的数据
            contentType: false,   // 告诉jQuery不要去设置Content-Type请求头
            success: function(data){
                alert(data);
                window.location.href="/data";
            },
        })
    })
</script>
</body>
</html>